package controller.teacher.manager;

import java.io.IOException;
import java.sql.SQLException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import view.DataList;

import dao.Student;

@WebServlet("/teacher/manager/add")
public class add extends Base {
    private static final long serialVersionUID = 1L;

    public add() {
        super();
    }

    protected void doGet(HttpServletRequest request,
            HttpServletResponse response) throws ServletException, IOException {
        view.displayMap("teacher/add.jsp");
    }

    protected void doPost(HttpServletRequest request,
            HttpServletResponse response) throws ServletException, IOException {
        try {
            String no = request.getParameter("no");
            String name = request.getParameter("name");
            String pwd = request.getParameter("pwd");
            Integer _class = new Integer(request.getParameter("class"));
            Student.insert(no, name, pwd, _class);
            view.sendRedirect(request.getContextPath() + "/teacher/manager/index");
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }
}
